// 属性列表
controllers.controller('rechargeOrderCtrl', ['$scope', '$http', '$rootScope', '$modal', '$window', 'RechargeOrder', 'AlertService',
    function ($scope, $http, $rootScope, $modal, $window, RechargeOrder, AlertService) {
        $scope.resetCurrentPageName("充值订单管理");
        $scope.pageSize = 10;
        $scope.currentPage = 1;
        $scope.rechargeOrderList = RechargeOrder.rechargeOrderList;
        $scope.rechargeOrderNo;
        $scope.outOrderNo;
        $scope.status;
        $scope.currentProperty = RechargeOrder.currentProperty;

        $scope.queryList = function () {
        	RechargeOrder.queryList($scope.rechargeOrderNo, $scope.outOrderNo, $scope.status, $scope.currentPage, $scope.pageSize, function () {
                $scope.totalItems = RechargeOrder.totalSceneCount;
            });
        };
        
        $scope.confirmRechargeOrder = function (rechargeOrderNo) {
        	RechargeOrder.confirmRechargeOrder(rechargeOrderNo, function () {
            });
        };
        
        $scope.queryList();

        var operateTemplate = "<button class='btn btn-primary btn-sm' ng-click='grid.appScope.confirmRechargeOrder(row.entity.rechargeOrderNo)'>确认</button>";

        $scope.gridOptions = {
            data: 'rechargeOrderList',
            enableColumnMenus: false,
            enableColumnResizing: true,
            rowHeight: 40,
            columnDefs: [
                {field: 'rechargeOrderNo', displayName: '充值订单号', width: "10%"},
                {field: 'pingxxId', displayName: 'ping++订单号', width: "10%"},
                {field: 'memberName', displayName: '会员名', width: 120},
                {field: 'amountStr', displayName: '充值金额', width: 80},
                {field: 'modeName', displayName: '充值方式', width: 80},
                {field: 'timeFinishedStr', displayName: '完成时间', width: 150},
                {field: 'statusName', displayName: '状态', width: "2%"},
            ]
        };
    }]);

//// 属性列表,选择情况下
//controllers.controller('propertyListSelectCtrl', ['$scope', '$http', '$rootScope', '$modal', 'Property', 'AlertService', function ($scope, $http, $rootScope, $modal, Property, AlertService) {
//    $scope.utils = Food.utils;
//    $scope.pageSize = 20;
//    $scope.propertyList = rechargeOrder.propertyList;
//    $scope.title = "";
//    $scope.propertyType;
//    $rootScope.selectedItemList = [];
//
//    $scope.innerOk = function () {
//        //获取已选择的列表
//        for (var entity in $scope.propertyList) {
//            if ($scope.propertyList[entity].selected) {
//                $rootScope.selectedItemList.push($scope.propertyList[entity]);
//            }
//        }
//        $rootScope.ok();
//    };

//    $scope.queryList = function () {
//
//        Property.queryList($scope.title, $scope.propertyType, $scope.currentPage, $scope.pageSize, function () {
//            $scope.totalItems = Property.totalSceneCount;
//        });
//    };
//    $scope.queryList();
//    $scope.selectedChange = function (entity) {
//        if (!entity.selected) {
//            entity.selected = true;
//        } else {
//            entity.selected = !entity.selected;
//        }
//    }
//
//    $scope.gridOptions = {
//        data: 'propertyList',
//        enableColumnMenus: false,
//        enableColumnResizing: true,
//        rowHeight: 40,
//        columnDefs: [
//            {
//                field: 'id',
//                displayName: '属性名称',
//                cellTemplate: '<input type="checkbox" ng-model="checked" ng-change="grid.appScope.selectedChange(row.entity)" />'
//            },
//            {field: 'title', displayName: '属性名称'},
//            {field: 'propertyType', displayName: '属性类型'},
//            {field: 'editType', displayName: '属性编辑类型'},
//            {field: 'userId', displayName: '创建者Id'},
//            {
//                field: 'status',
//                displayName: '状态',
//                cellTemplate: '<div>{{row.entity.state == 0 ? "停用" :"在用"}}</div>'
//            }
//        ]
//    };
//}]);

//// 新增属性
//controllers.controller('addPropertyCtrl', ['$scope', '$http', '$rootScope', '$modal', '$window', 'Property', 'AlertService', function ($scope, $http, $rootScope, $modal, $window, Property, AlertService) {
//    $scope.resetCurrentPageName("属性维护");
//    $scope.title = "";
//    $scope.editType = "";
//    $scope.propertyType = "";
//
//    $scope.addProperty = function () {
//        Property.insert($scope.title, $scope.editType, $scope.propertyType, function () {
//            AlertService.addAlert({type: 'success', msg: '操作成功! '}, 1000);
//            //更新页面哦
//            $window.location.href = "#property/propertyList";
//        });
//    };
//
//}]);

//// 属性详情
//controllers.controller('propertyDetailCtrl', ['$scope', '$http', '$rootScope', '$modal', '$window', 'Property', 'AlertService', function ($scope, $http, $rootScope, $modal, $window, Property, AlertService) {
//    $scope.resetCurrentPageName("属性维护");
//    $scope.currentProperty = Property.currentProperty;
//    $scope.propertyValueList = Property.propertyValueList;
//    $scope.totalItems = Property.propertyValueCount;
//    $scope.currentPage = 1;
//    $scope.pageSize = 10;
//    $scope.propertyValue = "";
//
//    $scope.queryList = function () {
//
//        Property.getPropertyValues($scope.currentProperty.id, $scope.currentPage, $scope.pageSize, function () {
//
//        });
//    };
//    $scope.queryList();
//
//    var operateTemplate = "<button class='btn btn-primary btn-sm' ng-click='grid.appScope.deletePropertyValue(row.entity.id)'>删除</button>";
//    $scope.gridOptions = {
//        data: 'propertyValueList',
//        enableColumnMenus: false,
//        enableColumnResizing: true,
//        rowHeight: 40,
//        columnDefs: [
//            {field: 'id', displayName: 'id'},
//            {field: 'value', displayName: '属性值'},
//            {
//                field: 'id',
//                displayName: '操作',
//                width: "30%",
//                cellTemplate: operateTemplate
//            }
//        ]
//    };
//    $scope.deletePropertyValue = function (id) {
//        Property.deletePropertyValue(id, function () {
//            AlertService.addAlert({type: 'success', msg: '操作成功! '}, 1000);
//        });
//    };
//
//    $scope.newPropertyValue = function () {
//
//        if (!$scope.propertyValue || /^\s*$/.test($scope.propertyValue)) {
//            AlertService.addAlert({type: 'danger', msg: '属性值不能为空! '}, 1000);
//        } else {
//            Property.insertPropertyValue($scope.currentProperty.id,$scope.currentProperty.title, $scope.propertyValue, function () {
//                AlertService.addAlert({type: 'success', msg: '操作成功! '}, 1000);
//            });
//        }
//    };
//
//}]);

//// 新增属性值
//controllers.controller('addPropertyValueCtrl', ['$scope', '$http', '$rootScope', '$modal', 'Property', 'AlertService', function ($scope, $http, $rootScope, $modal, Property, AlertService) {
//    $scope.resetCurrentPageName("属性维护");
//    $scope.propertyMetaId = "";
//    $scope.value = "";
//
//    $scope.addPropertyValue = function () {
//        Property.insertPropertyValue($scope.propertyMetaId, $scope.value, function () {
//            AlertService.addAlert({type: 'success', msg: '操作成功! '}, 1000);
//        });
//    };
//
//}]);

